package com.rainman.noswagger.def_interface;


import com.rainman.noswagger.core.ClassInfoInterface;
import com.rainman.noswagger.info_bean.AnnoInfoBean;
import com.rainman.noswagger.info_bean.ClassInfoBean;

/**
 * 默认预处理ClassInfo
 * 可自行通过设置替换
 *
 */
public class DefClassInfoWorker implements ClassInfoInterface {

    @Override
    public String getBaseUrl(ClassInfoBean classInfoBean) {
        for(AnnoInfoBean annoInfoBean:classInfoBean.getAnnoInfoBeanList()){

            if("RequestMapping".equals(annoInfoBean.getAnnoName())){
                return annoInfoBean.getFullInfo().split("\"")[1];
            }

        }
        return null;
    }

    @Override
    public Boolean isControllerClass(ClassInfoBean classInfoBean) {

        for(AnnoInfoBean annoInfoBean:classInfoBean.getAnnoInfoBeanList()){

            if("Controller".equals(annoInfoBean.getAnnoName())
                    ||"RestController".equals(annoInfoBean.getAnnoName())
            ){
                return true;
            }

        }
        return false;
    }


}
